﻿#include "IndexController.h"

IndexController::IndexController(){}

IndexController::~IndexController(){}

/**
 * 加载函数 一般做初始化UI和逻辑
 */
void IndexController::viewDidLoad(){
	CAButton* btn=CAButton::createWithLayout(DLayout(DHorizontalLayout_L_R(10, 10), DVerticalLayout_H_C(90, 0.3)), CAButton::Type::RoundedRect);
	btn->setTitleForState(CAControl::State::Normal, "跳转到下一页面");
	btn->setTitleFontSize(font.fontSize);
	btn->setTitleColorForState(CAControl::State::Normal, ccc4Int(CrossApp::hex2Int("0xff2ec0ff")));
	btn->addTarget([&]{
		getRootWindow()->pushViewController(IndexController::create(), true);
	}, CAButton::Event::TouchDown);
	this->getView()->addSubview(btn);
	btn=CAButton::createWithLayout(DLayout(DHorizontalLayout_W_C(300, 0.5), DVerticalLayout_H_C(90, 0.6)), CAButton::Type::RoundedRect);
	btn->setTitleForState(CAControl::State::Normal, "手机宽度");
	btn->setTitleFontSize(font.fontSize);
	btn->setTitleColorForState(CAControl::State::Normal, ccc4Int(CrossApp::hex2Int("0xff2ec0ff")));
	btn->addTarget([=]{
		getAlert(this->getView(), "数据解析异常, 请稍后重试");
	}, CAButton::Event::TouchDown);
	this->getView()->addSubview(btn);
}

/**
 * 卸载函数 一般做移除和释放
 */
void IndexController::viewDidUnload(){}

/**
 * 显示时被调用 一般重新加载数据时使用
 */
void IndexController::viewDidAppear(){}

/**
 * 隐藏时被调用
 */
void IndexController::viewDidDisappear(){}
